package com.cs.client;

import com.cs.service.UserService;
import io.netty.channel.ChannelFuture;
import org.apache.curator.framework.CuratorFramework;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;

public class RpcThread extends Thread{

    //存在的服务器集合
    public static Set<String> servers = new HashSet<>();


    public RpcThread() {

    }

    @Override
    public void run() {
        // TODO Auto-generated method stub
        //super.run();
            doRpc();
    }

    //RPC连接
    public void doRpc() {

            RpcConsumer rpcConsumer = new RpcConsumer();
            UserService proxy = (UserService) rpcConsumer.createProxy(UserService.class);
            try {
                System.out.println(proxy.sayHello("Who is the son of failure?"));
            }catch (Exception e){
                e.printStackTrace();
            }

            int  threadCount = ((ThreadPoolExecutor)ClientBootStrap.executor).getActiveCount();
            System.out.println("保持连接的服务器数量："+threadCount);


    }

}
